home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / 5tinydms / frm.si < prev    next >
Text File  |  1995-11-24  |  2KB  |  126 lines

  1.  
  2. **********************************************
  3. *                                            *
  4. *  A simple way of switching the CPU in FRM, *
  5. *   featuring up to 4Gb of linear memory !   *
  6. * (c)oderight LCA/Infiny and Jedi/Sector One *
  7. *                                            *
  8. **********************************************
  9.  
  10. * Set the CPU in Flat-Real-Mode : enjoy 4Gb of linear memory !
  11.  
  12. initFRM pusha.l
  13.         pushf
  14.  
  15.     smsw a
  16.     test.b #1,a
  17.     beq okay
  18.  
  19.         move cs,d
  20.         move d,ds
  21.         move #lame,d
  22.         move.b #9,ah
  23.         trap #$21
  24.         move #$4cff,a
  25.         trap #$21
  26.  
  27. lame    dc.b "Hey ! This program is good enough to manage its memory itself."
  28.         dc.b 13,10
  29.         dc.b "Please remove your memory manager (EMM, QEMM...) and try again."
  30.         dc.b 13,10,'$'
  31.  
  32. !ptrCode        set 8
  33. !ptrData        set 16
  34. !cSizeGDT       set 24
  35.  
  36. okay    move ds,d
  37.         move cs,a
  38.         move a,ds
  39.         move a,currentSeg
  40.  
  41.         movezx.l ax,ae
  42.         shl.l #4,a
  43.         move.l a,b
  44.         lea segmentGDT,si
  45.  
  46.         move a,!ptrCode+2(si)
  47.         move a,!ptrData+2(si)
  48.  
  49.         ror.l #16,a
  50.         move.b a,!ptrCode+4(si)
  51.         move.b a,!ptrData+4(si)
  52.  
  53.         move.b #0,!ptrCode+7(si)
  54.         move.b #0,!ptrData+7(si)
  55.  
  56.         xor.l a,a
  57.         move si,a
  58.         add.l a,b
  59.         move #!cSizeGDT,pointerGDT
  60.         move.l b,pointerGDT+2
  61.  
  62.         intoff
  63.         in.b #$70,a
  64.         cs:move.b a,saveNMI+1
  65.         or.b #$80,a
  66.         out.b a,$70
  67.  
  68.         lgdt pointerGDT
  69.  
  70.         move ss,b
  71.         move es,c
  72.  
  73.         move.l cr0,a
  74.         or.b #1,a
  75.         move.l a,cr0
  76.  
  77.         dc.b $66,$ea
  78.         dc.w pMode,0
  79.         dc.w !ptrCode
  80.  
  81. pMode   move #!ptrData,a
  82.         move a,ds
  83.         move a,es
  84.         move a,fs
  85.         move a,gs
  86.         move a,ss
  87.  
  88.         move.l cr0,a
  89.         and.b #254,a
  90.         move.l a,cr0
  91.  
  92.         dc.b $66,$ea
  93.         dc.w rMode,0
  94. currentSeg
  95.         dc.w 0
  96.  
  97. rMode   move b,ss
  98.         move d,ds
  99.         move c,es
  100.  
  101.         xor a,a
  102.         move a,fs
  103.         move a,gs
  104.  
  105. saveNMI move.b #$12,a
  106.         out.b a,$70
  107.         inton
  108.  
  109.         popf
  110.         popa.l
  111.         rts
  112.  
  113.         align.l
  114.  
  115. pointerGDT
  116.         ds.l 2
  117.  
  118. segmentGDT
  119.         ds.w 4
  120.         dc.w $ffff,0
  121.         dc.b 0,$9a
  122.         dc.w $9f
  123.         dc.w $ffff,0
  124.         dc.b 0,$92
  125.         dc.w $9f
  126.